const Mock = require('mockjs')

// const data = Mock.mock({
//   'items|30': [{
//     id: '@id',
//     title: '@sentence(10, 20)',
//     'status|1': ['published', 'draft', 'deleted'],
//     author: 'name',
//     display_time: '@datetime',
//     pageviews: '@integer(300, 5000)'
//   }]
// })
const data = Mock.mock({
  'items|10': [
    { title: '序号', field: 'serialNumber', editRender: { name: 'input', options: '', props: { type: 'integer' }}},
    { title: '编码', field: 'name', editRender: { name: 'input', options: '', props: { type: 'integer' }}},
    { title: '描述', field: 'desc', editRender: { name: 'input', options: '', props: { type: 'integer' }}},
    { title: '单位', field: 'unit', editRender: { name: 'input', options: '', props: { type: 'integer' }}},
    { title: '数量*', field: 'quantity*', editRender: { name: 'input', options: '', props: { type: 'integer' }}},
    { title: '当前版本', field: 'version', editRender: { name: 'input', options: '', props: { type: 'integer' }}},
    { title: '发布版本', field: 'deployVersion', editRender: { name: 'input', options: '', props: { type: 'integer' }}},
    { title: '位号', field: 'tag', editRender: { name: 'input', options: '', props: { type: 'integer' }}},
    { title: '替代料', field: 'alternativeMaterials', editRender: { name: 'input', options: '', props: { type: 'integer' }}},
    { title: '备注', field: 'status', editRender: { name: 'input', options: '', props: { type: 'integer' }}}
  ]
})
const children = [{ 'id': '7c5219ff-90a7-4cf7-979a-fba748d97c56', 'folderName': null, 'parentFileId': null, 'updateType': null, 'desc': '', 'objectType': '2', 'currentFileId': null, 'name': '测试添加文件夹4', 'version': '', 'status': '' }]
const data2 = Mock.mock({
  'items|10': [{
    'id|+1': '6ef97c466bce20feb9e20e33ef8bd149',
    'folderName': null,
    'parentFileId': null,
    'updateType': null,
    'desc': '关系测试2',
    'objectType': '1',
    'currentFileId': null,
    'name': 'AUTO-TTT_SSS0019',
    'version': '',
    'status': '3',
    'children|1-3': children
  }]
})

module.exports = [
  {
    url: '/mock/plm-sys/objectInstance/queryAutoBomList',
    type: 'get',
    response: config => {
      const items = data.items
      return {
        code: 200,
        data: {
          total: items.length,
          result: items
        }
      }
    }
  },
  {
    url: '/mock/plm-sys/objectInstance/queryPageBomList',
    type: 'post',
    response: config => {
      const items = data2.items
      return {
        code: 200,
        data: {
          total: items.length,
          result: items
        }
      }
    }
  }
]
